package cloud.provider.payment.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @auther xfanonymous
 * @create 2023-12-22 14:50
 *
 * Swagger3配置类
 *      1. 通过组件GroupedOpenApi对API进行分组说明
 *      2. 添加API说明配置
 */

@Configuration
public class Swagger3Config
{
    @Bean
    public GroupedOpenApi PayApi()
    {
        // pay开头的都是支付微服务模块
        return GroupedOpenApi.builder().group("支付微服务模块").pathsToMatch("/pay/**").build();
    }

    @Bean
    public GroupedOpenApi OtherApi()
    {
        // other开头的都是其它微服务模块
        return GroupedOpenApi.builder().group("其它微服务模块").pathsToMatch("/other/**", "/others").build();
    }

    @Bean
    public GroupedOpenApi CustomerApi()
    {
        // customer开头的都是客户微服务模块
        return GroupedOpenApi.builder().group("客户微服务模块").pathsToMatch("/customer/**", "/customers").build();
    }

    @Bean
    public OpenAPI docsOpenApi()
    {
        return new OpenAPI()
                .info(new Info().title("cloud2024")
                        .description("xfanonymous测试使用")
                        .version("v1.0"))
                .externalDocs(new ExternalDocumentation()
                        .description("author：xfanonymous")
                        .url("https://gitee.com/xfanonymous/cloud2024"));
    }
}

